const ObjId = require('../common/ObjId');

class CollectJob {
    constructor(obj) {
        this.id = obj.id;
        this.collect = obj.collect;
    }

    check() {
        // 验证 id
        let post = new ObjId(this, 'id');
        let flag = post.check();
        if (!flag.success) {
            return flag;
        }
        // 验证 collect
        try {
            this.collect = Boolean(this.collect);
        } catch (e) {
            return { success: false, err: "collect 参数类型应为 bool" };
        }
        return { success: true };
    }
}

module.exports = CollectJob;